package org.or5e.plugin.core.vo;

import java.util.List;

import javax.xml.bind.JAXBElement;

import org.or5e.plugin.pojo.itunes.Dict;

public class ITunesTrack {
	public String trackID = null;
	public String trackName = null;
	public String trackArtist = null;
	public String trackAlbumArtist = null;
	public String trackComposer = null;
	public String trackAlbum = null;
	public String trackGroping = null;
	public String trackGender = null;
	public String trackKind = null;
	public String trackSize = null;
	public String trackTotalTime = null;
	public String trackNumber = null;
	public String trackCount = null;
	public String trackYear = null;
	public String trackModified = null;
	public String trackAdded = null;
	public String trackBitrate = null;
	public String trackSampleRate = null;
	public String trackComents = null;
	public String trackCompilation = null;
	public String trackPersistanceID = null;
	public String trackType = null;
	public String trackLocation = null;
	public String trackFileFolderCount = null;
	public String trackFolderCount = null;
	public String trackDiskNumber = null;
	public String trackDiskCount = null;
	public String trackPlayedCount = null;
	public String trackPlayedDate = null;
	public String trackRating = null;
	public Boolean copyFile = Boolean.FALSE;
	public String loadValueOf = "";

	public String getTrackID() {
		return trackID;
	}
	public String getTrackDiskNumber() {
		return trackDiskNumber;
	}
	public void setTrackDiskNumber(String trackDiskNumber) {
		this.trackDiskNumber = trackDiskNumber;
	}
	public String getTrackDiskCount() {
		return trackDiskCount;
	}
	public void setTrackDiskCount(String trackDiskCount) {
		this.trackDiskCount = trackDiskCount;
	}
	public String getTrackPlayedCount() {
		return trackPlayedCount;
	}
	public void setTrackPlayedCount(String trackPlayedCount) {
		this.trackPlayedCount = trackPlayedCount;
	}
	public String getTrackPlayedDate() {
		return trackPlayedDate;
	}
	public void setTrackPlayedDate(String trackPlayedDate) {
		this.trackPlayedDate = trackPlayedDate;
	}
	public String getTrackRating() {
		return trackRating;
	}
	public void setTrackRating(String trackRating) {
		this.trackRating = trackRating;
	}
	public void setTrackID(String trackID) {
		this.trackID = trackID;
	}
	public String getTrackName() {
		return trackName;
	}
	public void setTrackName(String trackName) {
		this.trackName = trackName;
	}
	public String getTrackArtist() {
		return trackArtist;
	}
	public void setTrackArtist(String trackArtist) {
		this.trackArtist = trackArtist;
	}
	public String getTrackAlbumArtist() {
		return trackAlbumArtist;
	}
	public void setTrackAlbumArtist(String trackAlbumArtist) {
		this.trackAlbumArtist = trackAlbumArtist;
	}
	public String getTrackComposer() {
		return trackComposer;
	}
	public void setTrackComposer(String trackComposer) {
		this.trackComposer = trackComposer;
	}
	public String getTrackAlbum() {
		return trackAlbum;
	}
	public void setTrackAlbum(String trackAlbum) {
		this.trackAlbum = trackAlbum;
	}
	public String getTrackGroping() {
		return trackGroping;
	}
	public void setTrackGroping(String trackGroping) {
		this.trackGroping = trackGroping;
	}
	public String getTrackGender() {
		return trackGender;
	}
	public void setTrackGender(String trackGender) {
		this.trackGender = trackGender;
	}
	public String getTrackKind() {
		return trackKind;
	}
	public void setTrackKind(String trackKind) {
		this.trackKind = trackKind;
	}
	public String getTrackSize() {
		return trackSize;
	}
	public void setTrackSize(String trackSize) {
		this.trackSize = trackSize;
	}
	public String getTrackTotalTime() {
		return trackTotalTime;
	}
	public void setTrackTotalTime(String trackTotalTime) {
		this.trackTotalTime = trackTotalTime;
	}
	public String getTrackNumber() {
		return trackNumber;
	}
	public void setTrackNumber(String trackNumber) {
		this.trackNumber = trackNumber;
	}
	public String getTrackCount() {
		return trackCount;
	}
	public void setTrackCount(String trackCount) {
		this.trackCount = trackCount;
	}
	public String getTrackYear() {
		return trackYear;
	}
	public void setTrackYear(String trackYear) {
		this.trackYear = trackYear;
	}
	public String getTrackModified() {
		return trackModified;
	}
	public void setTrackModified(String trackModified) {
		this.trackModified = trackModified;
	}
	public String getTrackAdded() {
		return trackAdded;
	}
	public void setTrackAdded(String trackAdded) {
		this.trackAdded = trackAdded;
	}
	public String getTrackBitrate() {
		return trackBitrate;
	}
	public void setTrackBitrate(String trackBitrate) {
		this.trackBitrate = trackBitrate;
	}
	public String getTrackSampleRate() {
		return trackSampleRate;
	}
	public void setTrackSampleRate(String trackSampleRate) {
		this.trackSampleRate = trackSampleRate;
	}
	public String getTrackComents() {
		return trackComents;
	}
	public void setTrackComents(String trackComents) {
		this.trackComents = trackComents;
	}
	public String getTrackCompilation() {
		return trackCompilation;
	}
	public void setTrackCompilation(String trackCompilation) {
		this.trackCompilation = trackCompilation;
	}
	public String getTrackPersistanceID() {
		return trackPersistanceID;
	}
	public void setTrackPersistanceID(String trackPersistanceID) {
		this.trackPersistanceID = trackPersistanceID;
	}
	public String getTrackType() {
		return trackType;
	}
	public void setTrackType(String trackType) {
		this.trackType = trackType;
	}
	public String getTrackLocation() {
		return trackLocation;
	}
	public void setTrackLocation(String trackLocation) {
		this.trackLocation = trackLocation;
	}
	public String getTrackFileFolderCount() {
		return trackFileFolderCount;
	}
	public void setTrackFileFolderCount(String trackFileFolderCount) {
		this.trackFileFolderCount = trackFileFolderCount;
	}
	public String getTrackFolderCount() {
		return trackFolderCount;
	}
	public void setTrackFolderCount(String trackFolderCount) {
		this.trackFolderCount = trackFolderCount;
	}
	@SuppressWarnings("rawtypes")
	public void loadInfo(Dict keyDictObject) {
		List<Object> dictOrArrayOrData = keyDictObject.getDictOrArrayOrData();
		boolean isOddRead = Boolean.TRUE;
		for (Object dictCellData : dictOrArrayOrData) {
			if(dictCellData instanceof JAXBElement) {
				if(isOddRead) {
					String keyValue = (String)((JAXBElement) dictCellData).getValue();
					loadValueOf = keyValue.replaceAll(" ", "");
					isOddRead = false;
				}
				else {
					String valueToLoad = String.valueOf(((JAXBElement) dictCellData).getValue());
					loadValueOfCell(valueToLoad);
					isOddRead = true;
				}
			}
			else {
				isOddRead = !isOddRead;
			}
		}
	}
	private void loadValueOfCell(String valueToLoad) {
		loadValueOf = loadValueOf.toLowerCase();
		switch(loadValueOf) {
		case "trackid": this.trackID = valueToLoad; break;
		case "name": this.trackName = valueToLoad; break;
		case "artist": this.trackArtist = valueToLoad; break;
		case "albumartist": this.trackAlbumArtist = valueToLoad; break;
		case "composer": this.trackComposer = valueToLoad; break;
		case "album": this.trackAlbum = valueToLoad; break;
		case "groping": this.trackGroping = valueToLoad; break;
		case "gender": this.trackGender = valueToLoad; break;
		case "kind": this.trackKind = valueToLoad; break;
		case "size": this.trackSize = valueToLoad; break;
		case "totaltime": this.trackTotalTime = valueToLoad; break;
		case "tracknumber": this.trackNumber = valueToLoad; break;
		case "trackcount": this.trackCount = valueToLoad; break;
		case "year": this.trackYear = valueToLoad; break;
		case "datemodified": this.trackModified = valueToLoad; break;
		case "dateadded": this.trackAdded = valueToLoad; break;
		case "bitrate": this.trackBitrate = valueToLoad; break;
		case "samplerate": this.trackSampleRate = valueToLoad; break;
		case "coments": this.trackComents = valueToLoad; break;
		case "compilation": this.trackCompilation = valueToLoad; break;
		case "persistanceid": this.trackPersistanceID = valueToLoad; break;
		case "tracktype": this.trackType = valueToLoad; break;
		case "location": this.trackLocation = valueToLoad; break;
		case "filefoldercount": this.trackFileFolderCount = valueToLoad; break;
		case "foldercount": this.trackID = trackFolderCount; break;
		case "disknumber": this.trackDiskNumber = valueToLoad; break;
		case "diskcount": this.trackDiskCount = valueToLoad; break;
		case "playedcount": this.trackPlayedCount = valueToLoad; break;
		case "playeddate": this.trackPlayedDate = valueToLoad; break;
		case "rating": this.trackRating = valueToLoad; break;
		}
	}
	public Boolean copyFile() {
		return (this.trackType != null && this.trackType.equals("File") && this.trackLocation != null);
	}
	@Override public String toString() {
		return "["+this.trackID+":"+this.trackKind+":"+this.trackType+"]";
	}
}
